<template>
    <div id="login" >
        <div id="login_dv1">
            <div id="login_dv2" >
                <!-- <img src=""> -->
                <div id="login_dv5">
                    <div id="login_dv6">
                        <span class="iconfont">&#xe898;</span>
                        <span>饿了么</span>
                    </div>
                    <span>Everything 30`</span>
                </div>
                <div id="login_dv3"><a href="#">短信登录</a></div>
            </div>
            <div id="login_dv4">
                <section class="login_sec1"><input v-model="name" type="text" placeholder="手机号"><button>获取验证码</button></section>
                <section class="login_sec1"><input v-model="password" type="text" placeholder="验证码"></section>
                <section id="login_sec2">
                    温馨提示：未注册饿了么账号的手机号，登录时将自动注册，且代表您已同意
                    <a href="#">《用户服务协议》</a>
                </section>
                <button id="login_but1" @click="dd">登录</button>
            </div>
            <a href="#" id="login_a1">关于我们</a>
        </div>
    </div>
</template>
<script>
import axios from 'axios'
import md5 from 'js-md5'
// import Server from 'assets/js/config'
import {serverIP,serverPort} from 'assets/js/config'
let Base64 = require('js-base64').Base64;
import Cookie from '@/assets/js/ck'
export default {
    name:'login',
    data(){
        return{
            name:'',
            password:''
        }
    },
    methods:{
        dl(){
            let uname = this.name;
            let upassword = this.password;
            // console.log(md5(uname))
            let b64 = Base64.encode(uname);
            // console.log('加密后',b64);
            // console.log('解密后',Base64.decode(b64))
            // console.log(this.name,this.password)
            let url= 'http://192.168.0.182:10002/login'
            axios.post(url,{
                    uname:this.name,
                    upassword:this.password
            }).then((res)=>{
                console.log(res)
            }).catch((err)=>{
                console.log(err)
            })

        },

        dd () {
            console.log(1)
            let uname = this.name
            let upassword = this.password
            upassword = md5(upassword)
            let b64 = Base64.encode(upassword);
            // let url= Server.serverIP+':'+Server.serverPost+'/login'
            let url= serverIP+':'+serverPort+'/login'
            console.log(url)
            axios.post(url,{
                    uname:uname,
                    upassword:b64
            }).then((res)=>{
                if(res.data[0].uname){
                    window.location='http://127.0.0.1:8080/#/user'
                    localStorage.uname=res.data[0].uname
                    localStorage.uid=res.data[0].uid
                console.log('成功')
                }else{
                    alert('已注册')
                }
                console.log(res)
            }).catch((err)=>{
                console.log(err)
            })

            // Cookie.getCookie();
            // Cookie.setCookie('yjj','214444');
            // Cookie.getCookie()
            console.log(Cookie.getCookie('yjj'))
            

        }

    }
}
</script>
<style lang="stylus" scoped>
    input
        border 1px solid #000

#login
    height auto
    min-height 100%
    padding-top 40px
    #login_dv1
        flex 1 1 auto
        justify-content flex-start
        width 300px
        display flex
        flex-direction column
        margin 0 auto
        #login_dv2
            text-align center
            #login_dv5
                text-align center
                #login_dv6
                    color #2395ff
                    // font-size 1rem
                    span 
                        font-size .8rem
                span
                    color #2395ff
            #login_dv3
                margin-top 40px
                display flex
                justify-content center
                a
                    color #2395ff
                    font-weight 700
                    border-bottom 2px solid #2395ff
                    font-size 14px
                    padding-bottom 4px
                    cursor pointer
                    display block
                    width 58px
                    margin 0 20px
        #login_dv4
            .login_sec1
                position relative
                margin-top 16px
                height 48px
                font-size 14px
                background #fff
                input
                    width 100%
                    height 100%
                    left 0
                    padding-left 10px
                    border 1px solid #ddd
                    border-radius 4px
                    color #333
                    -webkit-appearance none
                    display inline-block
                    // position absolute
                    // top 50%
                    // right 10px
                button
                    color #ccc
                    padding 0
                    border-radius 6px
                    background transparent
                    text-align center
                    font-size 14px
                    display inline-block
                    position absolute
                    top 30%
                    right 10px
            #login_sec2
                    margin-top 12px
                    color #999
                    font-size 14px
                    line-height 20px
                    a
                        color #2395ff
            #login_but1
                display block
                width 100%
                height 42px
                margin-top 30px
                border-radius 4px
                background #4cd96f
                color #fff
                cursor pointer
                text-align center
                font-size 16px
                line-height 42px
        #login_a1
            display block
            margin-top 20px
            text-align center
            color #999
            




</style>
